class Solution {
public:
	ListNode* FindFirstCommonNode(ListNode* pHead1, ListNode* pHead2) {
		int count1 = 0;
		int count2 = 0;
		ListNode* max = pHead1;
		ListNode* min = pHead2;
		while (max)
		{
			count1++;
			max = max->next;
		}
		max = pHead1;
		while (min)
		{
			count2++;
			min = min->next;
		}
		min = pHead2;
		int count = count1 - count2;
		if (count2 > count1)
		{
			ListNode* tmp = max;
			max = min;
			min = tmp;
			count = count2 - count1;
		}
		while (count--)
			max = max->next;
		while (max != min)
		{
			max = max->next;
			min = min->next;
		}
		return min;
	}
};